let cookie = 'abc=123; username=huang; age=24';

let start = cookie.indexOf('=', cookie.indexOf('username'));
let end = cookie.indexOf(';', start);
let val = cookie.substring(start + 1, end);
console.log(val);